package com.wxhandle.cleandemo.core.domain.base;

import java.util.Date;

import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.domain.AbstractAggregateRoot;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class Auditable<T> extends AbstractAggregateRoot<Auditable<T>>  {
    @CreatedDate
    @Temporal(TemporalType.TIMESTAMP)
    Date createdOn;

    @LastModifiedDate
    @Temporal(TemporalType.TIMESTAMP)
    Date modifiedOn;

    @CreatedBy
    String createdBy;
    
    @LastModifiedBy
    String modifiedBy;
}
